<template>
  <div>
    <el-card>
      <el-row>
        <el-col :span="4">
          <img src="../assets/touxiang.jpg" alt />
        </el-col>
        <el-col :span="10">
          <template>
            <h1>{{uname}},{{timeTip}} 天行健，君子以自强不息!</h1>
          </template>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      timeTip: '',
      uname: '',
    }
  },
  created() {
    this.welcomeInfo()
  },
  methods: {
    welcomeInfo() {
      // 获取时间
      const date = new Date()
      const h = date.getHours()
      // console.log(h)
      if (h > 5 && h <= 8) {
        this.timeTip = '早上好！'
      } else if (h > 8 && h <= 10) {
        this.timeTip = '上午好！'
      } else if (h > 10 && h <= 13) {
        this.timeTip = '中午好！'
      } else if (h > 13 && h <= 18) {
        this.timeTip = '下午好！'
      } else {
        this.timeTip = '晚上好！'
      }

      // 获取用户名
      this.uname = window.sessionStorage.getItem('username')
    },
  },
}
</script>

<style lang="less" scoped>
img {
  width: 150px;
  border-radius: 50%;
}
.el-row {
  // display: flex;
  // align-content: center;
  height: 160px;
}
h1 {
  height: 160px;
  line-height: 160px;
}
</style>